package com.aaa.docter.service.Impl;

import com.aaa.docter.Fegin.MedicinaFeign;
import com.aaa.docter.dao.MedicinalDao;
import com.aaa.docter.service.MedicinesService;
import com.aaa.docter.vo.MedicinesVo;
import com.aaa.entity.Medicines;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.Objects;

@Service
public class MedicinesServiceImpl implements MedicinesService {

    @Autowired
    private MedicinalDao medicinalDao;

    @Autowired
    private MedicinaFeign medicinaFeign;

    @Override
    public Result<IPage<Medicines>> findByConditio(Integer currentPage, Integer pageSize, MedicinesVo medicinesVo) {
        IPage<Medicines> page = new Page<>(currentPage, pageSize);
        QueryWrapper<Medicines> wrapper = new QueryWrapper<>();
        //关键字
        if (StringUtils.hasText(medicinesVo.getKeywords())) {
            wrapper.like("keywords", medicinesVo.getKeywords());
        }
        IPage<Medicines> page1 = medicinalDao.selectPage(page, wrapper);
        return new Result<IPage<Medicines>>(2000, "查询用户成功", page1);


    }
}
